<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="//at.alicdn.com/t/font_1880456_8r13t3d4r3m.css">
<link rel="stylesheet" href="${request.contextPath}/static/css/gd-ui.css">
<header>
  <div class="wrapper">
    <a href="${contextPath}">
      <div class="bg-header_logo"></div>
    </a>
    <div class="search-wrap">
      <div class="input-wrap">
        <input type="text" placeholder="Please enter TikToker's name or username" onblur="hideSearch()" onfocus="showSearch()" oninput="searchBlogger(this.value)" class="header-input" maxlength="50">
        <i class="iconfont iconsousuo1"></i>
      </div>
      <div class="search-result" id="searchResult">
      </div>
    </div>
    <ul class="header-tab">
      <li class="<#if tab==1>is-active</#if>">
        <a href="${contextPath}">Home</a>
      </li>
      <li class="<#if tab==2>is-active</#if>">
        <a href="${contextPath}/help/home">Help Center</a>
      </li>
      <li class="more-tab" onmouseover="showPop(this)" onmouseout="hidePop(this)">
        <div>Hot TikTok</div>
        <i class="iconfont icondown1"></i>
        <ul class="pop-tabs" >
          <li class="<#if tab==3>is-active</#if>">
            <a href="${contextPath}/influencer/gdindex">Hot TikTok Influencer</a>
          </li>
          <li class="<#if tab==4>is-active</#if>">
            <a href="${contextPath}/video/spreadIndex/all">Hot TikTok Video</a>
          </li>
          <li class="<#if tab==8>is-active</#if>">
            <a href="${contextPath}/tiktok/sounds">Hot TikTok Sound</a>
          </li>
          <li class="<#if tab==7>is-active</#if>">
            <a href="${contextPath}/tiktok/hashtags">Hot TikTok Hashtag</a>
          </li>
          <li class="<#if tab==6>is-active</#if>">
            <a href="${contextPath}/tiktoker/comparison">TikTok Comparison</a>
          </li>
          <li class="<#if tab==12>is-active</#if>">
            <a href="${contextPath}/ranking/follower">Follower Growth Leaderboards</a>
          </li>
        </ul>
      </li>
      <li class="<#if tab==10>is-active</#if>">
        <a href="${contextPath}/pricing">Pricing</a>
      </li>
    </ul>
    <#if login == false>
      <a href="javascript:;" onclick="toLogin()" style="text-decoration: none;margin-left: auto;">
        <button class="small">Register/Login</button>
      </a>
    <#else>
      <a href="https://tk.gugeedata.com/#/elements/videos" style="text-decoration: none;margin-left: auto;">
        <button class="small">Get Started</button>
      </a>
    </#if>
  </div>
  <#include "./login/index.ftl">
  <script>
    getURLParams()
    let urlParams = ''
    function showPop (e) {
      e.querySelector('.pop-tabs').style.display = 'block'
    }
    function hidePop (e) {
      e.querySelector('.pop-tabs').style.display = 'none'
    }
    function jump(url){
      window.location.href = url + urlParams;
    }
    function getURLParams(){
      let url = window.location.href;
      if(url.indexOf('?') > 0){
        urlParams = url.substring(url.indexOf('?'),url.length);
      }
    }
    function toLogin() {
      <#if isMobile == true>
      document.getElementById('accountPage').hide()
      document.body.style.overflow = 'hidden'
      <#else>
      showMask({
        event: () => {
          hideLogin()
        }
      })
      </#if>
      let loginDom = document.querySelector('.login-section')
      if(document.documentElement.scrollTop > 0) {
        loginDom.style.top = 'calc(50% + ' + document.documentElement.scrollTop + 'px)'
      } else {
        loginDom.style.top = '50%'
      }
      loginDom.show()
      document.querySelectorAll('.login-section .login-wrap').forEach((item, index) => {
        if(index === 0) {
          item.show()
          document.querySelector('.login-section .login-footer-tx').innerHTML =
                  'Not registered yet? <a href="javascript:;" onclick="toRegister()">Create a new account</a>'
        }else {
          item.hide()
        }
      })
    }
    function hideLogin() {
      <#if isMobile == true>
      document.body.style.overflowY = 'auto'
      <#else>
      hideMask()
      </#if>
      document.querySelector('.login-section').hide()
    }
  </script>
  <script src="${request.contextPath}/static/js/base.js"></script>
  <script src="${request.contextPath}/static/plugins/axios.min.js"></script>
  <script src="${request.contextPath}/static/js/request.js"></script>
  <script>
    let searchResult = document.getElementById('searchResult')
    function searchBlogger(val) {
      searchResult.innerHTML = '<div class="loading"><i class="iconfont rotate icongengxin"></i></div>'
      loadBlogger(val)()
    }
    function showSearch() {
      searchResult.show()
    }
    function hideSearch() {
      setTimeout(() => {
        searchResult.hide()
      }, 300)
    }
    let timer
    function loadBlogger(val) {
      return () => {
        if(timer) {
          clearTimeout(timer)
        }
        timer = setTimeout(() => {
          timer = null
          _axios.get('/tiktoker/search?keyword='+val).then(res => {
            if(res.Code === 200) {
              let list = res.Data
              if(list.length > 0) {
                let con = '<div class="search-list">'
                list.forEach(item => {
                  con += '<div class="search-item" onclick="toBloggerDetail(\'' + item.uniqueId + '\')">' +
                          '              <div class="left">' +
                          '                <img src="' + item.avatar +'" alt="' + item.nickname + '">'
                  if(item.customVerify || item.enterpriseVerifyReason) {
                    con += '<i class="iconfont iconzhichi"></i>'
                  }
                  con += '              </div>' +
                          '              <div class="right">' +
                          '                <div class="user-name">' + item.nickname + '</div>' +
                          '                <div class="user-info">' + item.uniqueId + ' • Followers ' + item.followerCount + '</div>' +
                          '              </div>' +
                          '            </div>'
                })
                con += '</div>'
                searchResult.innerHTML = con
              } else {
                searchResult.innerHTML = '<div class="no-data">' +
                        '            <img src="${request.contextPath}/static/img/no-data.png">' +
                        '            <div>' +
                        '              No result that match your search.<br>' +
                        '              Please modify your keywords and try again.' +
                        '            </div>' +
                        '          </div>'
              }
            }
          })
        }, 1500)
      }
    }
    function toBloggerDetail(id) {
      window.location.href = '${contextPath}/tiktoker/' + id
    }
  </script>
</header>